package com.example.slidespresso;

import com.google.gwt.dom.client.Style.Unit;
import com.vaadin.Application;
import com.vaadin.event.LayoutEvents.LayoutClickEvent;
import com.vaadin.event.LayoutEvents.LayoutClickListener;
import com.vaadin.terminal.Sizeable;
import com.vaadin.terminal.ThemeResource;
import com.vaadin.terminal.gwt.client.ui.Icon;
import com.vaadin.ui.*;

public class SlidespressoApplication extends Application {
	/**
	 * 
	 */
	private static final long serialVersionUID = 4507538122394203080L;
	private Window mainWindow;
	private VerticalLayout vLayout, toolLayout, slideLayout, propLayout;
	private HorizontalLayout menuLayout, mainLayout;
	private MenuBar menuBar;
	private Accordion toolBox;
	private Panel slide, contentPanel;
	private GridLayout textTable, mediaTable, othersTable;
	private Label parafLabel, titleLabel, subtitleLabel;
	
	@Override
	public void init() {
		setTheme("SlidespressoTheme");
		
		//main window
		mainWindow = new Window("Slidespresso");
		//layouts
		vLayout = new VerticalLayout();
		menuLayout = new HorizontalLayout();
		mainLayout = new HorizontalLayout();
		toolLayout = new VerticalLayout();
		slideLayout = new VerticalLayout();
		
		//components
		menuBar = new MenuBar();
		toolBox = new Accordion();
		slide = new Panel();
		parafLabel = new Label("Paragraph");
		titleLabel = new Label("Title");
		subtitleLabel = new Label("SubTitle");
		textTable = new GridLayout();
		mediaTable = new GridLayout();
		othersTable = new GridLayout();
		
		//vLayout
		vLayout.setHeight("100%");
		vLayout.setWidth("100%");
		vLayout.addComponent(menuBar);
		vLayout.addComponent(mainLayout);
		
		//mainLayout
		mainLayout.setWidth("100%");
		mainLayout.setHeight("100%");
		mainLayout.addComponent(toolLayout);
		mainLayout.addComponent(slideLayout);
		
		//toollayout
		toolLayout.setWidth("15%");
		toolLayout.setHeight("100%");
		toolLayout.addComponent(toolBox);
		toolLayout.setComponentAlignment(toolBox, Alignment.TOP_LEFT);
		
		//slidelayout
		slideLayout.setWidth("70%");
		slideLayout.setHeight("100%");
		slideLayout.addComponent(slide);
		slideLayout.setComponentAlignment(slide, Alignment.TOP_CENTER);
		
		//menuLayout
		//menuLayout.setWidth("100%");
		//menuLayout.addComponent(menuBar);
		
		//menubar
		menuBar.setWidth("100%");
		menuBar.setHeight("5%");
		MenuBar.MenuItem fileMenu = menuBar.addItem("File", null);
		fileMenu.addItem("New", null);
		fileMenu.addItem("Save as HTML5", null);
		fileMenu.addItem("Export to XML", null);
		MenuBar.MenuItem editMenu = menuBar.addItem("Edit", null);
		editMenu.addItem("New Slide", null);
		editMenu.addItem("Delete Slide", null);
		MenuBar.MenuItem settingsMenu = menuBar.addItem("Settings", null);
		settingsMenu.addItem("Select Theme", null);
		settingsMenu.addItem("Select Animation", null);
		settingsMenu.addItem("Select Font", null);
		MenuBar.MenuItem helpMenu = menuBar.addItem("Help", null);
		helpMenu.addItem("NodeJS", null);
		helpMenu.addItem("About Slidespresso", null);
		
		//tables
		parafLabel.setIcon(new ThemeResource("img/paraf.ico"));
		titleLabel.setIcon(new ThemeResource("img/title.ico"));
		subtitleLabel.setIcon(new ThemeResource("img/subtitle.ico"));
		textTable.addComponent(parafLabel);
		textTable.addComponent(titleLabel);
		textTable.addComponent(subtitleLabel);
		
		//accordion
		toolBox.setStyleName("main-toolbox");
		TabSheet.Tab textTab = toolBox.addTab(textTable, "Text Objects", new ThemeResource("img/text.ico"));
		textTab.setDescription("Objects for adding text to the slide.");
		TabSheet.Tab mediaTab = toolBox.addTab(mediaTable, "Media Objects", new ThemeResource("img/media.ico"));
		mediaTab.setDescription("Objects for adding media to the slide");
		TabSheet.Tab othersTab = toolBox.addTab(othersTable, "Other Objects", new ThemeResource("img/others.ico"));
		othersTab.setDescription("Objects with various functions");
		
		//panel
		slide.setHeight("90%");
		slide.setStyleName("slide-panel");

		
		
		
		mainWindow.setContent(vLayout);
		setMainWindow(mainWindow);
	}

}
